package com.libmailcore;

import java.util.List;
import java.util.Date;

/** Message header. */
public class MessageHeader extends NativeObject {
    
    /** Constuctor. */
    public MessageHeader() {
        setupNative();
    }
    
    /** The constructor will parse the data encoded using RFC 822 and initializes
        the content using those data. */
    public MessageHeader(byte[] headersData) {
        setupNative();
        importHeadersData(headersData);
    }
    
    /** Returns the Message-ID. */
    public native String messageID();
    /** Sets the Message-ID. */
    public native void setMessageID(String messageID);
    
    /** Returns whether the Message-ID has been generated. */
    public native boolean isMessageIDAutoGenerated();
    
    /** Returns the References. */
    public native List<String> references();
    /** Sets the References. */
    public native void setReferences(List<String> references);
    
    /** Returns In-Reply-To. */
    public native List<String> inReplyTo();
    /** Sets In-Reply-To. */
    public native void setInReplyTo(List<String> inReplyTo);
    
    /** Returns Date. */
    public native Date date();
    /** Sets Date. */
    public native void setDate(Date date);
    
    /** Sets the received date (it's not part of the RFC 822 headers). */
    public native Date receivedDate();
    /** Returns the received date (it's not part of the RFC 822 headers). */
    public native void setReceivedDate(Date date);
    
    /** Returns Sender. */
    public native Address sender();
    /** Set Sender. */
    public native void setSender(Address sender);

    /** Return From. */
    public native Address from();
    /** Sets From. */
    public native void setFrom(Address from);
    
    /** Returns To. */
    public native List<Address> to();
    /** Sets To. */
    public native void setTo(List<Address> to);

    /** Returns Cc. */
    public native List<Address> cc();
    /** Sets Cc. */
    public native void setCc(List<Address> cc);

    /** Returns Bcc. */
    public native List<Address> bcc();
    /** Sets Bcc. */
    public native void setBcc(List<Address> bcc);

    /** Returns Reply-To. */
    public native List<Address> replyTo();
    /** Sets Reply-To. */
    public native void setReplyTo(List<Address> replyTo);

    /** Returns Subject. */
    public native String subject();
    /** Sets Subject. */
    public native void setSubject(String subject);

    /** Returns X-Mailer. */
    public native String userAgent();
    /** Sets X-Mailer. */
    public native void setUserAgent(String userAgent);
    
    /** Sets a custom header value. */
    public native void setExtraHeader(String name, String value);
    /** Remove a custom header. */
    public native void removeExtraHeader(String name);
    /** Returns the value of a custom header. */
    public native String extraHeaderValueForName(String name);
    /** Returns all the names of the custom headers. */
    public native List<String> allExtraHeadersNames();
    
    /** Returns the extracted subject (removing all the Re:, Fwd:, etc). Also removes brackets. */
    public native String extractedSubject();
    /** Returns extracted subject but do not remove brackets. */
    public native String partialExtractedSubject();
    
    /** Parsed the given data in RFC 822 format and sets the headers. */
    public native void importHeadersData(byte[] data);
    
    /** Generates a header that could be used for a reply message. */
    public native MessageHeader replyHeader(boolean replyAll, List<Address> excludedRecipients);
    /** Generates a header that could be used as a base for a forwarded message. */
    public native MessageHeader forwardHeader();
    
    private native void setupNative();

    private static final long serialVersionUID = 1L;
}
